package com.masterclient.app.modules.order;

import android.content.Intent;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.alibaba.android.arouter.launcher.ARouter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.eoner.baselibrary.bean.goods.PromotionBean;
import com.eoner.baselibrary.bean.order.OrderListBean;
import com.eoner.baselibrary.bean.order.OrderTipBean;
import com.eoner.baselibrary.utils.IntentUtil;
import com.eoner.baselibrary.utils.ScreenUtils;
import com.eoner.baselibrary.utils.TimeUtil;
import com.eoner.baselibrary.utils.Utils;
import com.eoner.baselibrary.utils.ViewTransformUtil;
import com.eoner.common.config.Config;
import com.eoner.managerlibrary.router.AroutePath;
import com.eoner.managerlibrary.sobot.SobotManager;
import com.masterclient.app.R;
import com.masterclient.app.base.ConfirmDialog;
import com.masterclient.app.base.FrozenDialog;
import com.masterclient.app.utils.CommonUtil;
import com.masterclient.app.widget.PriceIntegralLayout;
import com.sobot.chat.SobotApi;
import com.sobot.chat.api.enumtype.SobotChatTitleDisplayMode;
import com.sobot.chat.api.model.Information;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 作者：sean
 * 创建时间：2017/7/27 14:13
 * 功能说明：
 */

public class OrderListAdapter extends BaseQuickAdapter<OrderListBean.DataBean.ShDataBean, BaseViewHolder> {

    private String rechargeCenterUrl;
    private String fromType;

    public OrderListAdapter(String fromType) {
        super(R.layout.item_customer_order);
        this.fromType = TextUtils.isEmpty(fromType)?"":fromType;
    }

    public void setData(String rechargeCenterUrl) {
        this.rechargeCenterUrl = rechargeCenterUrl;
        notifyDataSetChanged();
    }

    @Override
    protected void convert(BaseViewHolder helper, OrderListBean.DataBean.ShDataBean item) {
        LinearLayout ll_op = helper.getView(R.id.ll_op);
        LinearLayout ll_op_sale = helper.getView(R.id.ll_op_sale);
        ll_op.setVisibility(View.VISIBLE);

        LinearLayout ll_shop = helper.getView(R.id.ll_shop);
        ImageView iv_shop_arrow = helper.getView(R.id.iv_shop_arrow);
        TextView tv_zsq_shop_tag = helper.getView(R.id.tv_zsq_shop_tag);
        TextView contactSeller = helper.getView(R.id.tv_contact_seller);
        contactSeller.setVisibility(View.GONE);

        RelativeLayout rl_title = helper.getView(R.id.rl_title);
        RelativeLayout rl_trade = helper.getView(R.id.rl_trade);
        if ("trade".equals(item.getSh_order_type())&&!"sale".equals(fromType)) {
            rl_title.setVisibility(View.GONE);
            rl_trade.setVisibility(View.VISIBLE);
        } else {
            rl_title.setVisibility(View.VISIBLE);
            rl_trade.setVisibility(View.GONE);
        }
//        ll_shop.setVisibility("sale".equals(fromType)?View.GONE:View.VISIBLE);

        //店铺名称
        TextView tv_shop_name = (TextView) helper.getView(R.id.tv_shop_name);
        TextView tv_shop_name_tag = (TextView) helper.getView(R.id.tv_shop_name_tag);


        if (item.getSh_order()!=null && item.getSh_order().getSh_type()!=null && item.getSh_order().getSh_type().equals("11")) {
            tv_zsq_shop_tag.setVisibility(View.VISIBLE);
        } else {
            tv_zsq_shop_tag.setVisibility(View.GONE);
        }

        helper.setGone(R.id.tv_bufa, item.getSh_order() != null && !TextUtils.isEmpty(item.getSh_order().getSh_type()) && "6".equals(item.getSh_order().getSh_type()));

        if (item.getSh_trade() != null) {//-----------------------------------------------------------------------------------交易单--------------------------------------------------------------

            helper.setText(R.id.tv_trade_no, new StringBuffer("下单时间：").append(item.getSh_trade().getSh_orders().get(0).getSh_create_at()).toString());
//            tv_sale_order_no.setText(new StringBuffer("下单时间：").append(item.getSh_trade().getSh_orders().get(0).getSh_create_at()).toString());
//            tv.setText(ordersBean.getSh_seller().getSh_store_name());

            helper.setText(R.id.tv_status, item.getSh_trade().getSh_status_label());
            //保管提货标识
            ImageView ivStorageOrder = helper.getView(R.id.iv_trade_storage_order);
            ivStorageOrder.setVisibility("26".equals(item.getSh_trade().getSh_orders().get(0).getSh_type())
                    ||"27".equals(item.getSh_trade().getSh_orders().get(0).getSh_type())||"28".equals(item.getSh_trade().getSh_orders().get(0).getSh_type())?View.VISIBLE:View.GONE);
            ivStorageOrder.setImageResource("27".equals(item.getSh_trade().getSh_orders().get(0).getSh_type())
                    ?R.mipmap.icon_pick_order:R.mipmap.icon_storage_order);

            //helper.setText(R.id.tv_price,"¥"+item.getSh_trade().getSh_subtotal());

//            TextView tv_price0 = (TextView) helper.getView(R.id.tv_price);
//            Utils.setDin(tv_price0,mContext);
//            Utils.set_price_style(tv_price0,"¥"+item.getSh_trade().getSh_subtotal());

            ((PriceIntegralLayout) helper.getView(R.id.ll_price)).setData(item.getSh_trade().getSh_grand_integral(), item.getSh_trade().getSh_subtotal());
//            Utils.set_price_style(mContext,tv_price0,12,item.getSh_trade().getSh_grand_integral(),item.getSh_trade().getSh_subtotal());

//            if(item.getSh_trade().getSh_grand_integral() != null && Float.valueOf(item.getSh_trade().getSh_grand_integral()) > 0){
//                String point = item.getSh_trade().getSh_grand_integral();
//                String str1 = "金币";
//                String  str2 = "+";
//                String str3 = "¥";
//                String money = item.getSh_trade().getSh_subtotal();
//                String content = point + str1 + str2 + str3 + money;
//                SpannableString spannableString = new SpannableString(content);
//                spannableString.setSpan(new RelativeSizeSpan(0.75f), point.length(), (point + str1).length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
//                spannableString.setSpan(new RelativeSizeSpan(0.75f),(point + str1 + str2).length(), (point + str1 + str2 + str3).length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
//                spannableString.setSpan(new StyleSpan(android.graphics.Typeface.BOLD),0,point.length(),Spannable.SPAN_INCLUSIVE_INCLUSIVE);
//                spannableString.setSpan(new StyleSpan(android.graphics.Typeface.BOLD),(point + str1).length(),(point + str1 + str2 + str3 + money).length(),Spannable.SPAN_INCLUSIVE_INCLUSIVE);
//                tv_price0.setText(spannableString);
//            }else{
//                Utils.set_price_style(
//                0,"¥ "+item.getSh_trade().getSh_subtotal());
//            }

            String discount_amount = "";
            if (item.getSh_trade().getSh_orders() != null && item.getSh_trade().getSh_orders().get(0) != null) {
                if (Float.valueOf(item.getSh_trade().getSh_discount_total()) > 0) {
                    discount_amount = " 已优惠：¥" + item.getSh_trade().getSh_discount_total();
                }
                helper.setText(R.id.tv_discount, "(含运费：¥" + item.getSh_trade().getSh_shipping_total() + discount_amount + ")");
            }

            helper.setText(R.id.tv_goods_num, item.getSh_product_num());
            LinearLayout ll_container = helper.getView(R.id.ll_container);

            ll_container.removeAllViews();
            for (OrderListBean.DataBean.ShDataBean.ShTradeBean.ShOrdersBean ordersBean : item.getSh_trade().getSh_orders()) {
                View view = View.inflate(mContext, R.layout.item_customer_order_shop, null);
                TextView tv = (TextView) view.findViewById(R.id.tv_shop_name);
                TextView tvShopNameTag = (TextView) view.findViewById(R.id.tv_shop_name_tag);
                TextView tv_shop_tag = (TextView) view.findViewById(R.id.tv_shop_tag);
                view.findViewById(R.id.ll_layout).setVisibility("sale".equals(fromType)?View.GONE:View.VISIBLE);

//                view.findViewById(R.id.iv_shop_arrow).setVisibility(ordersBean.getSh_seller()!=null&&!TextUtils.isEmpty(ordersBean.getSh_seller().getSh_is_jump())&&"false".equals(ordersBean.getSh_seller().getSh_is_jump())?View.GONE:View.VISIBLE);
//                iv_shop_arrow.setVisibility(ordersBean.getSh_seller()!=null&&!TextUtils.isEmpty(ordersBean.getSh_seller().getSh_is_jump())&&"false".equals(ordersBean.getSh_seller().getSh_is_jump())?View.GONE:View.VISIBLE);

                view.findViewById(R.id.ll_shop_layout).setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
//                        if (ordersBean.getSh_seller()!=null&&!TextUtils.isEmpty(ordersBean.getSh_seller().getSh_is_jump())&&"false".equals(ordersBean.getSh_seller().getSh_is_jump())) return;
//
//                        if ("3".equals(ordersBean.getSh_order_type())) {
//                            CommonUtil.goAnyWhere(mContext,  rechargeCenterUrl, "", "", "", "");
//                        } else {
//                            ARouter.getInstance().build(AroutePath.STORE_ACTIVITY)
//                                        .withString("is_dealer", "true".equals(ordersBean.getSh_seller().getSh_is_dealer())?"1":"0")
//                                        .withString("is_agent", "true".equals(ordersBean.getSh_seller().getSh_is_agent())?"1":"0")
//                                        .withString("store_id", ordersBean.getSh_seller().getSh_id()).navigation();
//                        }
                    }
                });

                if (ordersBean.getSh_seller() != null) {
                    //跨进商品Tag
                    if (!TextUtils.isEmpty(ordersBean.getSh_seller().getSh_seller_tag())) {
                        tv_shop_name_tag.setVisibility(View.VISIBLE);
                        tv_shop_name_tag.setText(ordersBean.getSh_seller().getSh_seller_tag());
                    } else {
                        tv_shop_name_tag.setVisibility(View.GONE);
                    }
                    tv_shop_name.setText(ordersBean.getSh_seller().getSh_store_name());

                    //跨进商品Tag
                    if (!TextUtils.isEmpty(ordersBean.getSh_seller().getSh_seller_tag())) {
                        tvShopNameTag.setVisibility(View.VISIBLE);
                        tvShopNameTag.setText(ordersBean.getSh_seller().getSh_seller_tag());
                    } else {
                        tvShopNameTag.setVisibility(View.GONE);
                    }
                    tv.setText(ordersBean.getSh_seller().getSh_store_name());
                }
                tv.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
//                        if (ordersBean.getSh_seller()!=null&&!TextUtils.isEmpty(ordersBean.getSh_seller().getSh_is_jump())&&"false".equals(ordersBean.getSh_seller().getSh_is_jump())) return;
//
//                        if ("3".equals(ordersBean.getSh_order_type())) {
//                            CommonUtil.goAnyWhere(mContext,  rechargeCenterUrl, "", "", "", "");
//                        } else {
//                            ARouter.getInstance().build(AroutePath.STORE_ACTIVITY)
//                                        .withString("is_dealer", "true".equals(ordersBean.getSh_seller().getSh_is_dealer())?"1":"0")
//                                        .withString("is_agent", "true".equals(ordersBean.getSh_seller().getSh_is_agent())?"1":"0")
//                                        .withString("store_id", ordersBean.getSh_seller().getSh_id()).navigation();
//                        }
                    }
                });
                ll_shop.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
//                        if (ordersBean.getSh_seller()!=null&&!TextUtils.isEmpty(ordersBean.getSh_seller().getSh_is_jump())&&"false".equals(ordersBean.getSh_seller().getSh_is_jump())) return;
//                        if ("3".equals(ordersBean.getSh_order_type())) {
//                            CommonUtil.goAnyWhere(mContext,  rechargeCenterUrl, "", "", "", "");
//                        } else {
//                            ARouter.getInstance().build(AroutePath.STORE_ACTIVITY)
//                                        .withString("is_dealer", "true".equals(ordersBean.getSh_seller().getSh_is_dealer())?"1":"0")
//                                        .withString("is_agent", "true".equals(ordersBean.getSh_seller().getSh_is_agent())?"1":"0")
//                                        .withString("store_id", ordersBean.getSh_seller().getSh_id()).navigation();
//                        }
                    }
                });

                contactSeller.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if (ordersBean.getSh_seller()!=null&&!TextUtils.isEmpty(ordersBean.getSh_seller().getSh_mobile())){
                            ConfirmDialog dialog = new ConfirmDialog(mContext,"是否拨打电话",null,ordersBean.getSh_seller().getSh_mobile(),"取消","确定","#FF6809");
                            dialog.setOnChooseListerner(new ConfirmDialog.OnChooseListerner() {
                                @Override
                                public void cancel() {
                                    dialog.dismiss();
                                }

                                @Override
                                public void confirm() {
                                    IntentUtil.toPhoneApp(mContext,ordersBean.getSh_seller().getSh_mobile());
                                    dialog.dismiss();
                                }
                            });
                            dialog.show();
                        }else {
                            Information info_seller = SobotManager.getBaseInfo();
                            SobotApi.setChatTitleDisplayMode(mContext, SobotChatTitleDisplayMode.Default, "");
                            if (!TextUtils.isEmpty(ordersBean.getSh_seller().getSh_sobot_app_key())) {
                                info_seller.setAppkey(ordersBean.getSh_seller().getSh_sobot_app_key());
                                //info_seller.setInitModeType(4);
                                SobotManager.setSobotFlow(mContext, ordersBean.getSh_seller().getSh_sobot_flow_company_id(),
                                        ordersBean.getSh_seller().getSh_sobot_flow_group_id(), "0");
                            }
                            if (ordersBean != null) {
                                Map<String, String> customInfo = new HashMap<String, String>();
                                customInfo.put("order_no", ordersBean.getSh_order_no());
                                customInfo.put("order_status", ordersBean.getSh_status());
                                info_seller.setCustomInfo(customInfo);
                                int totalFee = (int) Float.valueOf(ordersBean.getSh_should_pay_price()).floatValue();
                                String productName = "";
                                String productImageeUrl = "";
                                if (ordersBean.getSh_products().size() > 0) {
                                    productName = ordersBean.getSh_products().get(0).getSh_name();
                                    productImageeUrl = ordersBean.getSh_products().get(0).getSh_image();
                                }
                                SobotManager.setOrderCardInfo(info_seller, ordersBean.getSh_order_no(), ordersBean.getSh_status(), totalFee, ordersBean.getSh_product_num(), ordersBean.getSh_create_at(), productName, productImageeUrl);
                            }
                            SobotApi.startSobotChat(mContext, info_seller);
                        }
                    }
                });

                tv_shop_tag.setTypeface(Typeface.createFromAsset(mContext.getAssets(), "fonts/iconfont.ttf"));

                LinearLayout ll_shop_container = (LinearLayout) view.findViewById(R.id.ll_shop_container);
                ll_shop_container.setOnClickListener(v -> {
                    if ("sale".equals(fromType)){
                        ARouter.getInstance().build(AroutePath.SALE_ORDER_DETAIL_ACTIVITY)
                                .withString("order_no", ordersBean.getSh_order_no())
                                .navigation();
                    }else {
                    Intent intent = new Intent(mContext, OrderDetailActivity.class);
                    intent.putExtra("order_no", ordersBean.getSh_order_no());
                    intent.putExtra("from_type", fromType);
                    mContext.startActivity(intent);
                    }
                });
                ll_shop_container.removeAllViews();
                int i = 0;
                for (OrderListBean.DataBean.ShDataBean.ShTradeBean.ShOrdersBean.ShProductsBeanX productsBean : ordersBean.getSh_products()) {
                    View view_goods = View.inflate(mContext, R.layout.item_customer_order_shop_goods, null);
                    View v_divide = view_goods.findViewById(R.id.v_divide);
                    ImageView imageView = (ImageView) view_goods.findViewById(R.id.iv_good);
                    TextView tv_title = (TextView) view_goods.findViewById(R.id.tv_title);
                    TextView tv_sku = (TextView) view_goods.findViewById(R.id.tv_skus);
                    LinearLayout llSkuContainer = (LinearLayout) view_goods.findViewById(R.id.ll_sku_container);
                    PriceIntegralLayout ll_price = (PriceIntegralLayout) view_goods.findViewById(R.id.ll_price);
//                    Utils.setDin(tv_price,mContext);
                    TextView tv_gos_num = (TextView) view_goods.findViewById(R.id.tv_gos_num);
                    TextView tv_after_sale = (TextView) view_goods.findViewById(R.id.tv_after_sale);
                    ViewTransformUtil.glideImageView(mContext, productsBean.getSh_image(), imageView,
                            R.mipmap.defaults, ScreenUtils.dp2px(107), ScreenUtils.dp2px(107));
//                    App.picasso.load(productsBean.getSh_image())
//                            .transform(new NewPicassoRoundTransform(ScreenUtils.dp2px(4)))
//                            .resize(ScreenUtils.dp2px(107),ScreenUtils.dp2px(107))
//                            .error(R.mipmap.defaults).placeholder(R.mipmap.defaults).into(imageView);
                    tv_title.setText(productsBean.getSh_name());

                    //商品提货数量
                    View rlPrice = view_goods.findViewById(R.id.rl_price);
                    TextView pickGoodNum = view_goods.findViewById(R.id.tv_pick_good_num);
                    if (!TextUtils.isEmpty(ordersBean.getSh_type())&&"27".equals(ordersBean.getSh_type())){
                        rlPrice.setVisibility(View.GONE);
                        pickGoodNum.setVisibility(View.VISIBLE);
                        pickGoodNum.setText(new StringBuffer("提货数量 ").append(productsBean.getSh_buy_qty()).toString());
                    }else {
                        rlPrice.setVisibility(View.VISIBLE);
                        pickGoodNum.setVisibility(View.GONE);
                    }


                    view_goods.findViewById(R.id.view_line).setVisibility(i == ordersBean.getSh_products().size()-1?View.VISIBLE:View.GONE);
                    if (i == 0) {
                        v_divide.setVisibility(View.GONE);
                    } else {
                        v_divide.setVisibility(View.VISIBLE);
                    }

                    i++;

                    if (TextUtils.isEmpty(productsBean.getSh_aftersale_status_label())) {
                        tv_after_sale.setVisibility(View.GONE);
                    } else {
                        tv_after_sale.setText(productsBean.getSh_aftersale_status_label());
                        tv_after_sale.setVisibility(View.VISIBLE);
                    }
                    //sku显示(分普通商品显示和话费充值商品显示)
                    if ("1".equals(productsBean.getSh_biz_type())) {
                        llSkuContainer.setVisibility(View.VISIBLE);
                        tv_sku.setVisibility(View.GONE);
                        List<OrderListBean.DataBean.ShDataBean.ShTradeBean.ShOrdersBean.ShProductsBeanX.ShPropertyBeanX> sh_property = productsBean.getSh_property();
                        if (sh_property != null && sh_property.size() > 0) {
                            llSkuContainer.setVisibility(View.VISIBLE);
                            llSkuContainer.removeAllViews();
                            for (OrderListBean.DataBean.ShDataBean.ShTradeBean.ShOrdersBean.ShProductsBeanX.ShPropertyBeanX propertyBean : sh_property) {
                                View viewSku = View.inflate(mContext, R.layout.item_sku_info, null);
                                TextView tvSkus = viewSku.findViewById(R.id.tv_skus);
                                tvSkus.setText(propertyBean.getSh_attribute_label() + ":" + propertyBean.getSh_alias_name());
                                llSkuContainer.addView(viewSku);
                            }
                        } else {
                            llSkuContainer.setVisibility(View.GONE);
                        }
                    } else {
                        llSkuContainer.setVisibility(View.GONE);
                        tv_sku.setVisibility(View.VISIBLE);
                        String skus = "";
                        List<OrderListBean.DataBean.ShDataBean.ShTradeBean.ShOrdersBean.ShProductsBeanX.ShPropertyBeanX> sh_property = productsBean.getSh_property();
                        for (OrderListBean.DataBean.ShDataBean.ShTradeBean.ShOrdersBean.ShProductsBeanX.ShPropertyBeanX propertyBean : sh_property) {
                            skus += ("“" + propertyBean.getSh_alias_name() + "”");
                        }
                        tv_sku.setText("规格：" + skus);
                    }
                    //tv_price.setText("¥"+productsBean.getSh_price());


                    view_goods.findViewById(R.id.tag_price_vip).setVisibility(productsBean.isSh_show_vip_price()?View.VISIBLE:View.GONE);
                    if (productsBean.isSh_show_vip_price()){
                        ll_price.setData( "", productsBean.getSh_vip_price());
                    }else {
                        ll_price.setData((int) (Float.valueOf(productsBean.getSh_integral()) / Float.valueOf(productsBean.getSh_buy_qty())) + "", productsBean.getSh_price());
                    }
//                    Utils.set_price_style(mContext,tv_price,12,(int) (Float.valueOf(productsBean.getSh_integral()) / Float.valueOf(productsBean.getSh_buy_qty()))+"",productsBean.getSh_price());

//                    if(productsBean.getSh_integral() != null && Float.valueOf(productsBean.getSh_integral()) > 0){
//                        int temp = (int) (Float.valueOf(productsBean.getSh_integral()) / Float.valueOf(productsBean.getSh_buy_qty()));
//                        String content = temp + " 金币";
//                        SpannableString spannableString = new SpannableString(content);
//                        spannableString.setSpan(new RelativeSizeSpan(0.75f), content.length()-3, content.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
//                        tv_price.setText(spannableString);
////                        tv_price.setText(temp + "金币");
//                    }else{
//                        Utils.set_price_style(tv_price,"¥ "+productsBean.getSh_price());
//                    }
                    tv_gos_num.setText("x" + productsBean.getSh_buy_qty());
                    //赠品列表
                    LinearLayout view_present = (LinearLayout) view_goods.findViewById(R.id.view_present);
                    LinearLayout ll_shop_present_container = (LinearLayout) view_goods.findViewById(R.id.ll_shop_present_container);
                    if (productsBean.getSh_promotion() != null && productsBean.getSh_promotion().size() > 0) {
                        view_present.setVisibility(View.VISIBLE);
                        ll_shop_present_container.setVisibility(View.VISIBLE);
                        ll_shop_present_container.removeAllViews();
                        for (PromotionBean promotionBean : productsBean.getSh_promotion()) {
                            View view_present_goods = View.inflate(mContext, R.layout.item_present, null);
                            ImageView ivPresentGood = view_present_goods.findViewById(R.id.iv_good);
                            TextView tvPresentTitle = view_present_goods.findViewById(R.id.tv_title);
                            TextView tvPresentSkus = view_present_goods.findViewById(R.id.tv_skus);
                            TextView tvPresentPrice = view_present_goods.findViewById(R.id.tv_price);
                            TextView tvPresentNum = view_present_goods.findViewById(R.id.tv_num);
                            view_present_goods.setOnClickListener(view1 -> {
                                if (promotionBean.shType != null) {
                                    CommonUtil.goAnyWhere(mContext,  promotionBean.shType, promotionBean.shTargetId, "", "", "");
                                }
                            });

                            ViewTransformUtil.glideImageView(mContext, promotionBean.shProductImg, ivPresentGood,
                                    R.mipmap.defaults);
                            tvPresentTitle.setText(promotionBean.shName);
                            String skuStr = "";
                            for (String sku : promotionBean.shSku) {
                                skuStr = skuStr + sku;
                            }
                            tvPresentSkus.setText(skuStr);
                            tvPresentPrice.setText("¥" + promotionBean.shPrice);
                            tvPresentNum.setText("x" + promotionBean.shQty);
                            ll_shop_present_container.addView(view_present_goods);
                        }
                    } else {
                        view_present.setVisibility(View.GONE);
                        ll_shop_present_container.setVisibility(View.GONE);
                    }
                    ll_shop_container.addView(view_goods);
                }
                ll_container.addView(view);
            }

            TextView v_update_address = helper.getView(R.id.tv_update_address);
            if ("1".equals(item.getSh_button().getSh_modify_address_btn())) {
                ll_op.setVisibility(View.VISIBLE);
                v_update_address.setVisibility(View.VISIBLE);
                v_update_address.setOnClickListener(v -> {
                    if (onButtonClickListener != null) {
                        onButtonClickListener.updateAddress(item.getSh_trade().getSh_id(),"");
                    }
                });
            } else {
                v_update_address.setVisibility(View.GONE);
            }

            TextView tv_cancle_order = helper.getView(R.id.tv_cancle_order);
            if ("1".equals(item.getSh_button().getSh_cancel_btn())) {
                ll_op.setVisibility(View.VISIBLE);
                tv_cancle_order.setVisibility(View.VISIBLE);
                tv_cancle_order.setOnClickListener(v -> {
                    if (onButtonClickListener != null) {
                        ConfirmDialog confirmDialog = new ConfirmDialog(mContext, "确定取消该订单？", "取消", "确定","purchase".equals(fromType)||"sale".equals(fromType)?"#FF6809":"");

                        confirmDialog.setOnChooseListerner(new ConfirmDialog.OnChooseListerner() {
                            @Override
                            public void cancel() {
                                confirmDialog.dismiss();
                            }

                            @Override
                            public void confirm() {
                                onButtonClickListener.cancleOrder("", item.getSh_trade().getSh_trade_no());
                                confirmDialog.dismiss();
                            }
                        });
                        confirmDialog.show();
                    }
                });
            } else {
                tv_cancle_order.setVisibility(View.GONE);
            }


            TextView tv_delete_order = helper.getView(R.id.tv_delete_order);

            if ("1".equals(item.getSh_button().getSh_delete_btn())) {
                ll_op.setVisibility(View.VISIBLE);
                tv_delete_order.setVisibility(View.VISIBLE);
                tv_delete_order.setOnClickListener(v -> {
                    if (onButtonClickListener != null) {
                        ConfirmDialog confirmDialog = new ConfirmDialog(mContext, "确定删除该订单？", "取消", "确定","purchase".equals(fromType)||"sale".equals(fromType)?"#FF6809":"");
                        confirmDialog.setOnChooseListerner(new ConfirmDialog.OnChooseListerner() {
                            @Override
                            public void cancel() {
                                confirmDialog.dismiss();
                            }

                            @Override
                            public void confirm() {
                                onButtonClickListener.removeOrder(item.getSh_trade().getSh_orders().get(0).getSh_order_no());
                                confirmDialog.dismiss();
                            }
                        });
                        confirmDialog.show();
                    }
                });
            } else {
                tv_delete_order.setVisibility(View.GONE);
            }
            TextView tv_delivery = helper.getView(R.id.tv_delivery);
            if ("1".equals(item.getSh_button().getSh_trade_btn())) {
                ll_op.setVisibility(View.VISIBLE);
                tv_delivery.setVisibility(View.VISIBLE);
                tv_delivery.setOnClickListener(v -> {
                    if (onButtonClickListener != null) {
                        onButtonClickListener.getLogistInfo(item.getSh_trade().getSh_orders().get(0).getSh_order_no(),
                                item.getSh_trade().getSh_orders().get(0).getSh_order_type());
                    }
                });
            } else {
                tv_delivery.setVisibility(View.GONE);
            }
            TextView tv_pay = helper.getView(R.id.tv_pay);
            if ("1".equals(item.getSh_button().getSh_payment_btn())) {
                ll_op.setVisibility(View.VISIBLE);
                tv_pay.setVisibility(View.VISIBLE);
                tv_pay.setOnClickListener(v -> {
                    if (onButtonClickListener != null) {
                        onButtonClickListener.payNow(item.getSh_trade().getSh_trade_no(), item.getSh_trade().getSh_orders().get(0).getSh_type());
                    }
                });
            } else {
                tv_pay.setVisibility(View.GONE);
            }
            TextView tv_confirm_order = helper.getView(R.id.tv_confirm_order);
            if ("1".equals(item.getSh_button().getSh_confirm_btn())) {
                ll_op.setVisibility(View.VISIBLE);
                tv_confirm_order.setVisibility(View.VISIBLE);
                tv_confirm_order.setOnClickListener(v -> {
                    if (onButtonClickListener != null) {

                        ConfirmDialog confirmDialog = new ConfirmDialog(mContext, "您是否已经收到货了？", "取消", "确定","purchase".equals(fromType)||"sale".equals(fromType)?"#FF6809":"");
                        confirmDialog.setOnChooseListerner(new ConfirmDialog.OnChooseListerner() {
                            @Override
                            public void cancel() {
                                confirmDialog.dismiss();
                            }

                            @Override
                            public void confirm() {
                                onButtonClickListener.recieverOrder(item.getSh_trade().getSh_orders().get(0).getSh_id());
                                confirmDialog.dismiss();
                            }
                        });
                        confirmDialog.show();
                    }
                });
            } else {
                tv_confirm_order.setVisibility(View.GONE);
            }
            TextView tv_comment = helper.getView(R.id.tv_comment);
            if ("1".equals(item.getSh_button().getSh_review_btn())) {
                ll_op.setVisibility(View.VISIBLE);
                tv_comment.setVisibility(View.VISIBLE);
                tv_comment.setOnClickListener(v -> {
                    if ("2".equals(Config.FROZEN)) {
                        FrozenDialog.showFrozen(mContext);
                        return;
                    }
                    if (onButtonClickListener != null) {
                        onButtonClickListener.toComment(item.getSh_trade().getSh_orders().get(0).getSh_order_no());
                    }
                });
            } else {
                tv_comment.setVisibility(View.GONE);
            }

            ll_op.setVisibility("sale".equals(fromType)?View.GONE:View.VISIBLE);

//            ll_op_sale.setVisibility("1".equals(item.getSh_button().getUp_reserve_btn())||
//                    "1".equals(item.getSh_button().getPick_up_btn())|| "1".equals(item.getSh_button()
//                    .getSend_btn())||"1".equals(item.getSh_button().getDelivery_btn())||"1".equals
//                    (item.getSh_button().getAdd_track_btn())||"1".equals(item.getSh_button()
//                    .getView_track_btn())?View.VISIBLE:View.GONE);
//            TextView tvUpReserve = helper.getView(R.id.tv_up_reserve);
//            if ("1".equals(item.getSh_button().getUp_reserve_btn())){
//                ll_op_sale.setVisibility(View.VISIBLE);
//                tvUpReserve.setVisibility(View.VISIBLE);
//                tvUpReserve.setOnClickListener(new View.OnClickListener() {
//                    @Override
//                    public void onClick(View v) {
//                        ConfirmDialog dialog = new ConfirmDialog(mContext, "点击确定后，该订单将会自动向上采购", "取消", "确认","#FF6809");
//                        dialog.setOnChooseListerner(new ConfirmDialog.OnChooseListerner() {
//                            @Override
//                            public void cancel() {
//                                dialog.dismiss();
//                            }
//
//                            @Override
//                            public void confirm() {
//                                onButtonClickListener.toUpReserve(item.getSh_trade().getSh_orders().get(0).getSh_id());
//                                dialog.dismiss();
//                            }
//                        });
//                        dialog.show();
//                    }
//                });
//            }else {
//                tvUpReserve.setVisibility(View.GONE);
//            }
//
//            TextView tvUpPick = helper.getView(R.id.tv_up_pick);
//            if ("1".equals(item.getSh_button().getPick_up_btn())){
//                ll_op_sale.setVisibility(View.VISIBLE);
//                tvUpPick.setVisibility(View.VISIBLE);
//                tvUpPick.setOnClickListener(new View.OnClickListener() {
//                    @Override
//                    public void onClick(View v) {
//                        ConfirmDialog dialog = new ConfirmDialog(mContext, "使用您在公司仓库保管的库存，发给您的卖家，您需要支付代发运费", "取消", "确定","#FF6809");
//                        dialog.setOnChooseListerner(new ConfirmDialog.OnChooseListerner() {
//                            @Override
//                            public void cancel() {
//                                dialog.dismiss();
//                            }
//
//                            @Override
//                            public void confirm() {
//                                onButtonClickListener.toPickUp(helper.getAdapterPosition(),item.getSh_trade().getSh_orders().get(0).getSh_id());
//                                dialog.dismiss();
//                            }
//                        });
//                        dialog.show();
//
//                    }
//                });
//            }else {
//                tvUpPick.setVisibility(View.GONE);
//            }
//
//            TextView tvSend = helper.getView(R.id.tv_send);
//            if ("1".equals(item.getSh_button().getSend_btn())){
//                ll_op_sale.setVisibility(View.VISIBLE);
//                tvSend.setVisibility(View.VISIBLE);
//                tvSend.setOnClickListener(new View.OnClickListener() {
//                    @Override
//                    public void onClick(View v) {
//                        onButtonClickListener.toSend(0,item.getSh_trade().getSh_orders().get(0).getSh_id());
//                    }
//                });
//            }else {
//                tvSend.setVisibility(View.GONE);
//            }
//
//            TextView tvSendDelivery = helper.getView(R.id.tv_send_delivery);
//            if ("1".equals(item.getSh_button().getDelivery_btn())){
//                ll_op_sale.setVisibility(View.VISIBLE);
//                tvSendDelivery.setVisibility(View.VISIBLE);
//                tvSendDelivery.setOnClickListener(new View.OnClickListener() {
//                    @Override
//                    public void onClick(View v) {
//                        ConfirmDialog dialog = new ConfirmDialog(mContext, "库存将划给下级经销商，请确定是否拨货？", "取消", "确认拨货","#FF6809");
//                        dialog.setOnChooseListerner(new ConfirmDialog.OnChooseListerner() {
//                            @Override
//                            public void cancel() {
//                                dialog.dismiss();
//                            }
//
//                            @Override
//                            public void confirm() {
//                                onButtonClickListener.toSendDelivery(helper.getAdapterPosition(),item.getSh_trade().getSh_orders().get(0).getSh_id());
//                                dialog.dismiss();
//                            }
//                        });
//                        dialog.show();
//                    }
//                });
//            }else {
//                tvSendDelivery.setVisibility(View.GONE);
//            }
//
//            TextView tvAgainSend = helper.getView(R.id.tv_again_send);
//            if ("1".equals(item.getSh_button().getAdd_track_btn())){
//                ll_op_sale.setVisibility(View.VISIBLE);
//                tvAgainSend.setVisibility(View.VISIBLE);
//                tvAgainSend.setOnClickListener(new View.OnClickListener() {
//                    @Override
//                    public void onClick(View v) {
//                        onButtonClickListener.toSend(1,item.getSh_trade().getSh_orders().get(0).getSh_id());
//                    }
//                });
//            }else {
//                tvAgainSend.setVisibility(View.GONE);
//            }
//
//            TextView tv_sale_logistics = helper.getView(R.id.tv_sale_logistics);
//            if ("1".equals(item.getSh_button().getView_track_btn())) {
//                ll_op_sale.setVisibility(View.VISIBLE);
//                tv_sale_logistics.setVisibility(View.VISIBLE);
//                tv_sale_logistics.setOnClickListener(v -> {
//                    if (onButtonClickListener != null) {
//                        onButtonClickListener.getLogistInfo(item.getSh_trade().getSh_orders().get(0).getSh_order_no(),
//                                item.getSh_trade().getSh_orders().get(0).getSh_order_type());
//                    }
//                });
//            } else {
//                tv_sale_logistics.setVisibility(View.GONE);
//            }



            if ("purchase".equals(fromType)||"sale".equals(fromType)){
                int colorPurchase = Color.parseColor("#FF6809");
                rl_trade.setBackgroundResource(R.drawable.purchase_order_trade_bg);
                ((TextView)helper.getView(R.id.tv_trade_status)).setTextColor(colorPurchase);
                ((PriceIntegralLayout) helper.getView(R.id.ll_price)).setPriceTextColor("purchase".equals(fromType)
                        ?colorPurchase:Color.parseColor("#141922"));
                ((TextView)helper.getView(R.id.tv_status)).setTextColor(colorPurchase);
                tv_delete_order.setTextColor(colorPurchase);
                tv_delete_order.setBackgroundResource(R.drawable.shape_round_line_ff6809);
                tv_pay.setTextColor(colorPurchase);
                tv_pay.setBackgroundResource(R.drawable.shape_round_line_ff6809);
                tv_confirm_order.setTextColor(colorPurchase);
                tv_confirm_order.setBackgroundResource(R.drawable.shape_round_line_ff6809);
                tv_comment.setTextColor(colorPurchase);
                tv_comment.setBackgroundResource(R.drawable.shape_round_line_ff6809);
            }

//            if("0".equals(item.getSh_button().getSh_cancel_btn())
//                    &&"0".equals(item.getSh_button().getSh_delete_btn())
//                    &&"0".equals(item.getSh_button().getSh_trade_btn())
//                    &&"0".equals(item.getSh_button().getSh_payment_btn())
//                    &&"0".equals(item.getSh_button().getSh_confirm_btn())
//                    &&"0".equals(item.getSh_button().getSh_review_btn())){
//                ll_op.setVisibility(View.GONE);
//            }
        } else if (item.getSh_order() != null) {//-----------------------------------------------------------------------------------订单--------------------------------------------------------------
//            helper.setText(R.id.tv_order_no,"订单编号："+item.getSh_order().getSh_order_no());
            helper.setText(R.id.tv_status, item.getSh_order().getSh_status_label());
            //保管提货标识
            ImageView ivStorageOrder = helper.getView(R.id.iv_storage_order);
            ivStorageOrder.setVisibility("26".equals(item.getSh_order().getSh_type())
                    ||"27".equals(item.getSh_order().getSh_type())||"28".equals(item.getSh_order().getSh_type())?View.VISIBLE:View.GONE);
            ivStorageOrder.setImageResource("27".equals(item.getSh_order().getSh_type())
                    ?R.mipmap.icon_pick_order:R.mipmap.icon_storage_order);

            //helper.setText(R.id.tv_price,"¥"+item.getSh_order().getSh_subtotal());
//            TextView tv_price1 = (TextView) helper.getView(R.id.tv_price);

            ((PriceIntegralLayout) helper.getView(R.id.ll_price)).setData(item.getSh_order().getSh_grand_integral(), item.getSh_order().getSh_subtotal());
//                ((PriceIntegralLayout)helper.getView(R.id.ll_price)).setData("888888888888","8888888888.88");

            //Utils.set_price_style(tv_price1,"¥"+item.getSh_order().getSh_subtotal());
//                Utils.set_price_style(mContext,tv_price1,12,item.getSh_order().getSh_grand_integral(),item.getSh_order().getSh_subtotal());
//                Utils.setDin(tv_price1,mContext);
//            if(item.getSh_order().getSh_grand_integral() != null && Float.valueOf(item.getSh_order().getSh_grand_integral()) > 0){
//                String point = item.getSh_order().getSh_grand_integral();
//                String str1 = "金币";
//                String  str2 = "+";
//                String str3 = "¥";
//                String money = item.getSh_order().getSh_subtotal();
//                String content = point + str1 + str2 + str3 + money;
//                SpannableString spannableString = new SpannableString(content);
//                spannableString.setSpan(new RelativeSizeSpan(0.75f), point.length(), (point + str1).length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
//                spannableString.setSpan(new RelativeSizeSpan(0.75f),(point + str1 + str2).length(), (point + str1 + str2 + str3).length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
//                spannableString.setSpan(new StyleSpan(android.graphics.Typeface.BOLD),0,point.length(),Spannable.SPAN_INCLUSIVE_INCLUSIVE);
//                spannableString.setSpan(new StyleSpan(android.graphics.Typeface.BOLD),(point + str1).length(),(point + str1 + str2 + str3 + money).length(),Spannable.SPAN_INCLUSIVE_INCLUSIVE);
//                tv_price1.setText(spannableString);
//            }else{
//                Utils.set_price_style(tv_price1,"¥ "+item.getSh_order().getSh_subtotal());
//            }

//            tv_sale_order_no.setText(new StringBuffer("下单时间：").append(item.getSh_order().getSh_create_at()).toString());


            String discount_amount = "";
            if (item.getSh_order() != null) {
                if (Float.valueOf(item.getSh_order().getSh_discount_amount()) > 0) {
                    discount_amount = " 已优惠：¥" + item.getSh_order().getSh_discount_amount();
                }
                helper.setText(R.id.tv_discount, "(含运费：¥" + item.getSh_order().getSh_shipping_amount() + discount_amount + ")");
            }
            helper.setText(R.id.tv_goods_num, item.getSh_product_num());

            LinearLayout ll_container = helper.getView(R.id.ll_container);

            ll_container.removeAllViews();
            View view = View.inflate(mContext, R.layout.item_customer_order_shop, null);
            view.findViewById(R.id.ll_layout).setVisibility(View.GONE);
            TextView tvShopNameTag = (TextView) view.findViewById(R.id.tv_shop_name_tag);
            TextView tv = (TextView) view.findViewById(R.id.tv_shop_name);

            if (item.getSh_order().getSh_seller()!=null) {
                //跨进商品Tag
                if (!TextUtils.isEmpty(item.getSh_order().getSh_seller().getSh_seller_tag())) {
                    tvShopNameTag.setVisibility(View.VISIBLE);
                    tvShopNameTag.setText(item.getSh_order().getSh_seller().getSh_seller_tag());
                } else {
                    tvShopNameTag.setVisibility(View.GONE);
                }
                tv.setText(item.getSh_order().getSh_seller().getSh_store_name());

                //跨进商品Tag
                if (!TextUtils.isEmpty(item.getSh_order().getSh_seller().getSh_seller_tag())) {
                    tv_shop_name_tag.setVisibility(View.VISIBLE);
                    tv_shop_name_tag.setText(item.getSh_order().getSh_seller().getSh_seller_tag());
                } else {
                    tv_shop_name_tag.setVisibility(View.GONE);
                }
                tv_shop_name.setText(item.getSh_order().getSh_seller().getSh_store_name());
            }

//            view.findViewById(R.id.iv_shop_arrow).setVisibility(item.getSh_order().getSh_seller()!=null&&!TextUtils.isEmpty(item.getSh_order().getSh_seller().getSh_is_jump())&&"false".equals(item.getSh_order().getSh_seller().getSh_is_jump())?View.GONE:View.VISIBLE);
//            iv_shop_arrow.setVisibility(item.getSh_order().getSh_seller()!=null&&!TextUtils.isEmpty(item.getSh_order().getSh_seller().getSh_is_jump())&&"false".equals(item.getSh_order().getSh_seller().getSh_is_jump())?View.GONE:View.VISIBLE);

            tv.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
//                    if (item.getSh_order().getSh_seller()!=null&&!TextUtils.isEmpty(item.getSh_order().getSh_seller().getSh_is_jump())&&"false".equals(item.getSh_order().getSh_seller().getSh_is_jump())) return;
//
//                    if ("3".equals(item.getSh_order().getSh_order_type())){
//                        CommonUtil.goAnyWhere(mContext,  rechargeCenterUrl, "", "", "", "");
//                    }else {
//                        ARouter.getInstance().build(AroutePath.STORE_ACTIVITY)
//                                    .withString("is_dealer", "true".equals(item.getSh_order().getSh_seller().getSh_is_dealer())?"1":"0")
//                                    .withString("is_agent", "true".equals(item.getSh_order().getSh_seller().getSh_is_agent())?"1":"0")
//                                    .withString("store_id", item.getSh_order().getSh_seller().getSh_id()).navigation();
//                    }

                }
            });

            ll_shop.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
//                    if (item.getSh_order().getSh_seller()!=null&&!TextUtils.isEmpty(item.getSh_order().getSh_seller().getSh_is_jump())&&"false".equals(item.getSh_order().getSh_seller().getSh_is_jump())) return;
//
//                    if ("3".equals(item.getSh_order().getSh_order_type())){
//                        CommonUtil.goAnyWhere(mContext, rechargeCenterUrl, "", "", "", "");
//                    }else {
//                        ARouter.getInstance().build(AroutePath.STORE_ACTIVITY)
//                                    .withString("is_dealer", "true".equals(item.getSh_order().getSh_seller().getSh_is_dealer())?"1":"0")
//                                    .withString("is_agent", "true".equals(item.getSh_order().getSh_seller().getSh_is_agent())?"1":"0")
//                                    .withString("store_id", item.getSh_order().getSh_seller().getSh_id()).navigation();
//                    }
                }
            });

            contactSeller.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (item.getSh_order().getSh_seller()!=null&&!TextUtils.isEmpty(item.getSh_order().getSh_seller().getSh_mobile())){
                        ConfirmDialog dialog = new ConfirmDialog(mContext,"是否拨打电话",null,item.getSh_order().getSh_seller().getSh_mobile(),"取消","确定","#FF6809");
                        dialog.setOnChooseListerner(new ConfirmDialog.OnChooseListerner() {
                            @Override
                            public void cancel() {
                                dialog.dismiss();
                            }

                            @Override
                            public void confirm() {
                                IntentUtil.toPhoneApp(mContext,item.getSh_order().getSh_seller().getSh_mobile());
                                dialog.dismiss();
                            }
                        });
                        dialog.show();
                    }else {
                        Information info_seller = SobotManager.getBaseInfo();
                        SobotApi.setChatTitleDisplayMode(mContext, SobotChatTitleDisplayMode.Default, "");
                        if (!TextUtils.isEmpty(item.getSh_order().getSh_seller().getSh_sobot_app_key())) {
                            info_seller.setAppkey(item.getSh_order().getSh_seller().getSh_sobot_app_key());
                            //info_seller.setInitModeType(4);
                            SobotManager.setSobotFlow(mContext, item.getSh_order().getSh_seller().getSh_sobot_flow_company_id(),
                                    item.getSh_order().getSh_seller().getSh_sobot_flow_group_id(), "0");
                        }
                        if (item.getSh_order() != null) {
                            Map<String, String> customInfo = new HashMap<String, String>();
                            customInfo.put("order_no", item.getSh_order().getSh_order_no());
                            customInfo.put("order_status", item.getSh_order().getSh_status());
                            info_seller.setCustomInfo(customInfo);
                            int totalFee = (int) Float.valueOf(item.getSh_order().getSh_should_pay_price()).floatValue();
                            String productName = "";
                            String productImageeUrl = "";
                            if (item.getSh_order().getSh_products().size() > 0) {
                                productName = item.getSh_order().getSh_products().get(0).getSh_name();
                                productImageeUrl = item.getSh_order().getSh_products().get(0).getSh_image();
                            }
                            SobotManager.setOrderCardInfo(info_seller, item.getSh_order().getSh_order_no(), item.getSh_order().getSh_status(), totalFee, item.getSh_product_num(), item.getSh_order().getSh_create_at(), productName, productImageeUrl);
                        }
                        SobotApi.startSobotChat(mContext, info_seller);
                    }

                }
            });


            LinearLayout ll_shop_container = (LinearLayout) view.findViewById(R.id.ll_shop_container);
            ll_shop_container.setOnClickListener(v -> {
                        if ("sale".equals(fromType)){
                            ARouter.getInstance().build(AroutePath.SALE_ORDER_DETAIL_ACTIVITY)
                                    .withString("order_no", item.getSh_order().getSh_order_no())
                                    .navigation();
                        }else {
                            Intent intent = new Intent(mContext, OrderDetailActivity.class);
                            intent.putExtra("order_no", item.getSh_order().getSh_order_no());
                            intent.putExtra("from_type", fromType);
                            mContext.startActivity(intent);
                        }
            });
            ll_shop_container.removeAllViews();
            int i = 0;
            for (OrderListBean.DataBean.ShDataBean.ShOrderBean.ShProductsBean productsBean : item.getSh_order().getSh_products()) {
                View view_goods = View.inflate(mContext, R.layout.item_customer_order_shop_goods, null);
                View v_divide = view_goods.findViewById(R.id.v_divide);
                ImageView imageView = (ImageView) view_goods.findViewById(R.id.iv_good);
                TextView tv_title = (TextView) view_goods.findViewById(R.id.tv_title);
                TextView tv_sku = (TextView) view_goods.findViewById(R.id.tv_skus);
                LinearLayout llSkuContainer = (LinearLayout) view_goods.findViewById(R.id.ll_sku_container);
                PriceIntegralLayout ll_price = (PriceIntegralLayout) view_goods.findViewById(R.id.ll_price);
                TextView tv_gos_num = (TextView) view_goods.findViewById(R.id.tv_gos_num);
                TextView tv_after_sale = (TextView) view_goods.findViewById(R.id.tv_after_sale);
                if (!TextUtils.isEmpty(productsBean.getSh_image())) {
                    ViewTransformUtil.glideImageView(mContext, productsBean.getSh_image(), imageView,
                            R.mipmap.defaults, ScreenUtils.dp2px(107), ScreenUtils.dp2px(107));
//                        App.picasso.load(productsBean.getSh_image())
//                                .transform(new NewPicassoRoundTransform(ScreenUtils.dp2px(4)))
//                                .resize(ScreenUtils.dp2px(107),ScreenUtils.dp2px(107))
//                                .error(R.mipmap.defaults).placeholder(R.mipmap.defaults).into(imageView);
                }
                tv_title.setText(productsBean.getSh_name());

                //商品提货数量
                View rlPrice = view_goods.findViewById(R.id.rl_price);
                TextView pickGoodNum = view_goods.findViewById(R.id.tv_pick_good_num);
                if (!TextUtils.isEmpty(item.getSh_order().getSh_type())&&"27".equals(item.getSh_order().getSh_type())){
                    rlPrice.setVisibility(View.GONE);
                    pickGoodNum.setVisibility(View.VISIBLE);
                    pickGoodNum.setText(new StringBuffer("提货数量 ").append(productsBean.getSh_buy_qty()).toString());
                }else {
                    rlPrice.setVisibility(View.VISIBLE);
                    pickGoodNum.setVisibility(View.GONE);
                }

                view_goods.findViewById(R.id.view_line).setVisibility(i == item.getSh_order().getSh_products().size()-1?View.VISIBLE:View.GONE);


                if (i == 0) {
                    v_divide.setVisibility(View.GONE);
                } else {
                    v_divide.setVisibility(View.VISIBLE);
                }
                i++;

                //sku显示(分普通商品显示和话费充值商品显示)
                if ("1".equals(productsBean.getSh_biz_type())) {
                    llSkuContainer.setVisibility(View.VISIBLE);
                    tv_sku.setVisibility(View.GONE);
                    List<OrderListBean.DataBean.ShDataBean.ShOrderBean.ShProductsBean.ShPropertyBean> sh_property = productsBean.getSh_property();
                    if (sh_property != null && sh_property.size() > 0) {
                        llSkuContainer.setVisibility(View.VISIBLE);
                        llSkuContainer.removeAllViews();
                        for (OrderListBean.DataBean.ShDataBean.ShOrderBean.ShProductsBean.ShPropertyBean propertyBean : sh_property) {
                            View viewSku = View.inflate(mContext, R.layout.item_sku_info, null);
                            TextView tvSkus = viewSku.findViewById(R.id.tv_skus);
                            tvSkus.setText(propertyBean.getSh_attribute_label() + ":" + propertyBean.getSh_alias_name());
                            llSkuContainer.addView(viewSku);
                        }
                    } else {
                        llSkuContainer.setVisibility(View.GONE);
                    }
                } else {
                    llSkuContainer.setVisibility(View.GONE);
                    tv_sku.setVisibility(View.VISIBLE);
                    if (!"sale".equals(fromType)) {
                        String skus = "";
                        List<OrderListBean.DataBean.ShDataBean.ShOrderBean.ShProductsBean.ShPropertyBean> sh_property = productsBean.getSh_property();
                        if (sh_property != null) {
                            for (OrderListBean.DataBean.ShDataBean.ShOrderBean.ShProductsBean.ShPropertyBean propertyBean : sh_property) {
                                skus += ("“" + propertyBean.getSh_alias_name() + "”");
                            }
                        }

                        tv_sku.setText("规格：" + skus);
                    }else {
                        tv_sku.setText("规格：" + productsBean.getAttribute_desc());
                    }
                }

                if (TextUtils.isEmpty(productsBean.getSh_aftersale_status_label())) {
                    tv_after_sale.setVisibility(View.GONE);
                } else {
                    tv_after_sale.setText(productsBean.getSh_aftersale_status_label());
                    tv_after_sale.setVisibility(View.VISIBLE);
                }

                //tv_price.setText("¥"+productsBean.getSh_price());
                //Utils.set_price_style(tv_price,"¥"+productsBean.getSh_price());
//                    Utils.setDin(tv_price,mContext);
//                    Utils.set_price_style(mContext,tv_price,12,(int) (Float.valueOf(productsBean.getSh_integral()) / Float.valueOf(productsBean.getSh_buy_qty()))+"",productsBean.getSh_price());

                view_goods.findViewById(R.id.tag_price_vip).setVisibility(productsBean.isSh_show_vip_price()?View.VISIBLE:View.GONE);
                if (productsBean.isSh_show_vip_price()){
                    ll_price.setData( "", productsBean.getSh_vip_price());
                }else {
                    ll_price.setData((int) (Float.valueOf(TextUtils.isEmpty(productsBean.getSh_integral())?"0":productsBean.getSh_integral())
                            / Float.valueOf(TextUtils.isEmpty(productsBean.getSh_buy_qty())?"1":productsBean.getSh_buy_qty())) + "", productsBean.getSh_price());
                }
//                    ll_price.setData("888888888",8888888888.88");
//                    if(productsBean.getSh_integ0ral() != null && Float.valueOf(productsBean.getSh_integral()) > 0){
//                        //tv_price.setText(productsBean.getSh_integral() + "金币");
//                        int temp = (int) (Float.valueOf(productsBean.getSh_integral()) / Float.valueOf(productsBean.getSh_buy_qty()));
//                        String content = temp + " 金币";
//                        SpannableString spannableString = new SpannableString(content);
//                        spannableString.setSpan(new RelativeSizeSpan(0.75f), content.length()-3, content.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
//                        tv_price.setText(spannableString);
////                        tv_price.setText(temp + "金币");
//                    }else{
//                        Utils.set_price_style(tv_price,"¥ "+productsBean.getSh_price());
//                    }


                tv_gos_num.setText("x" + productsBean.getSh_buy_qty());
                //赠品列表
                LinearLayout view_present = (LinearLayout) view_goods.findViewById(R.id.view_present);
                LinearLayout ll_shop_present_container = (LinearLayout) view_goods.findViewById(R.id.ll_shop_present_container);
                if (productsBean.getSh_promotion() != null && productsBean.getSh_promotion().size() > 0) {
                    view_present.setVisibility(View.VISIBLE);
                    ll_shop_present_container.setVisibility(View.VISIBLE);
                    ll_shop_present_container.removeAllViews();
                    for (PromotionBean promotionBean : productsBean.getSh_promotion()) {
                        View view_present_goods = View.inflate(mContext, R.layout.item_present, null);
                        ImageView ivPresentGood = view_present_goods.findViewById(R.id.iv_good);
                        TextView tvPresentTitle = view_present_goods.findViewById(R.id.tv_title);
                        TextView tvPresentSkus = view_present_goods.findViewById(R.id.tv_skus);
                        TextView tvPresentPrice = view_present_goods.findViewById(R.id.tv_price);
                        TextView tvPresentNum = view_present_goods.findViewById(R.id.tv_num);
                        view_present_goods.setOnClickListener(view1 -> {
                            if (promotionBean.shType != null) {
                                CommonUtil.goAnyWhere(mContext,  promotionBean.shType, promotionBean.shTargetId, "", "", "");
                            }
                        });

                        ViewTransformUtil.glideImageView(mContext, promotionBean.shProductImg, ivPresentGood,
                                R.mipmap.defaults);
                        tvPresentTitle.setText(promotionBean.shName);
                        String skuStr = "";
                        for (String sku : promotionBean.shSku) {
                            skuStr = skuStr + sku;
                        }
                        tvPresentSkus.setText(skuStr);
                        tvPresentPrice.setText("¥" + promotionBean.shPrice);
                        tvPresentNum.setText("x" + promotionBean.shQty);
                        ll_shop_present_container.addView(view_present_goods);
                    }
                } else {
                    view_present.setVisibility(View.GONE);
                    ll_shop_present_container.setVisibility(View.GONE);
                }
                ll_shop_container.addView(view_goods);
            }
            ll_container.addView(view);

            TextView v_update_address = helper.getView(R.id.tv_update_address);
            if (!TextUtils.isEmpty(item.getSh_button().getSh_modify_address_btn())&&"1".equals(item.getSh_button().getSh_modify_address_btn())) {
                ll_op.setVisibility(View.VISIBLE);
                v_update_address.setVisibility(View.VISIBLE);
                v_update_address.setOnClickListener(v -> {
                    if (onButtonClickListener != null) {
                        onButtonClickListener.updateAddress("",item.getSh_order().getSh_id());
                    }
                });
            } else {
                v_update_address.setVisibility(View.GONE);
            }

            TextView tv_cancle_order = helper.getView(R.id.tv_cancle_order);
            if (!TextUtils.isEmpty(item.getSh_button().getSh_cancel_btn())&&"1".equals(item.getSh_button().getSh_cancel_btn())) {
                ll_op.setVisibility(View.VISIBLE);
                tv_cancle_order.setVisibility(View.VISIBLE);
                tv_cancle_order.setOnClickListener(v -> {
                    if (onButtonClickListener != null) {

                        ConfirmDialog confirmDialog = new ConfirmDialog(mContext, "确定取消该订单？", "取消", "确定","purchase".equals(fromType)||"sale".equals(fromType)?"#FF6809":"");
                        confirmDialog.setOnChooseListerner(new ConfirmDialog.OnChooseListerner() {
                            @Override
                            public void cancel() {
                                confirmDialog.dismiss();
                            }

                            @Override
                            public void confirm() {
                                onButtonClickListener.cancleOrder("", item.getSh_order().getSh_order_no());
                                confirmDialog.dismiss();
                            }
                        });
                        confirmDialog.show();

                    }
                });
            } else {
                tv_cancle_order.setVisibility(View.GONE);
            }

            TextView tv_delete_order = helper.getView(R.id.tv_delete_order);

            if (!TextUtils.isEmpty(item.getSh_button().getSh_delete_btn())&&"1".equals(item.getSh_button().getSh_delete_btn())) {
                ll_op.setVisibility(View.VISIBLE);
                tv_delete_order.setVisibility(View.VISIBLE);
                tv_delete_order.setOnClickListener(v -> {
                    if (onButtonClickListener != null) {

                        ConfirmDialog confirmDialog = new ConfirmDialog(mContext, "确定删除该订单？", "取消", "确定","purchase".equals(fromType)||"sale".equals(fromType)?"#FF6809":"");
                        confirmDialog.setOnChooseListerner(new ConfirmDialog.OnChooseListerner() {
                            @Override
                            public void cancel() {
                                confirmDialog.dismiss();
                            }

                            @Override
                            public void confirm() {
                                onButtonClickListener.removeOrder(item.getSh_order().getSh_order_no());
                                confirmDialog.dismiss();
                            }
                        });
                        confirmDialog.show();
                    }
                });
            } else {
                tv_delete_order.setVisibility(View.GONE);
            }
            TextView tv_delivery = helper.getView(R.id.tv_delivery);
            if (!TextUtils.isEmpty(item.getSh_button().getSh_trade_btn())&&"1".equals(item.getSh_button().getSh_trade_btn())) {
                ll_op.setVisibility(View.VISIBLE);
                tv_delivery.setVisibility(View.VISIBLE);
                tv_delivery.setOnClickListener(v -> {
                    if (onButtonClickListener != null) {
                        onButtonClickListener.getLogistInfo(item.getSh_order().getSh_id(),
                                item.getSh_order().getSh_order_type());
                    }
                });
            } else {
                tv_delivery.setVisibility(View.GONE);
            }
            TextView tv_pay = helper.getView(R.id.tv_pay);
            if (!TextUtils.isEmpty(item.getSh_button().getSh_payment_btn())&&"1".equals(item.getSh_button().getSh_payment_btn())) {
                ll_op.setVisibility(View.VISIBLE);
                tv_pay.setVisibility(View.VISIBLE);
                tv_pay.setOnClickListener(v -> {
                    if (onButtonClickListener != null) {
                        onButtonClickListener.payNow(item.getSh_order().getSh_trade_id(), item.getSh_trade().getSh_orders().get(0).getSh_type());
                    }
                });
            } else {
                tv_pay.setVisibility(View.GONE);
            }
            TextView tv_confirm_order = helper.getView(R.id.tv_confirm_order);
            if (!TextUtils.isEmpty(item.getSh_button().getSh_confirm_btn())&&"1".equals(item.getSh_button().getSh_confirm_btn())) {
                ll_op.setVisibility(View.VISIBLE);
                tv_confirm_order.setVisibility(View.VISIBLE);
                tv_confirm_order.setOnClickListener(v -> {
                    if (onButtonClickListener != null) {

                        ConfirmDialog confirmDialog = new ConfirmDialog(mContext, "您是否已经收到货了？", "取消", "确定","purchase".equals(fromType)||"sale".equals(fromType)?"#FF6809":"");
                        confirmDialog.setOnChooseListerner(new ConfirmDialog.OnChooseListerner() {
                            @Override
                            public void cancel() {
                                confirmDialog.dismiss();
                            }

                            @Override
                            public void confirm() {
                                onButtonClickListener.recieverOrder(item.getSh_order().getSh_id());
                                confirmDialog.dismiss();
                            }
                        });
                        confirmDialog.show();

                    }
                });
            } else {
                tv_confirm_order.setVisibility(View.GONE);
            }
            TextView tv_comment = helper.getView(R.id.tv_comment);
            if (item.getSh_button()!=null&&!TextUtils.isEmpty(item.getSh_button().getSh_review_btn())&&"1".equals(item.getSh_button().getSh_review_btn())) {
                ll_op.setVisibility(View.VISIBLE);
                tv_comment.setVisibility(View.VISIBLE);
                tv_comment.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if ("2".equals(Config.FROZEN)) {
                            FrozenDialog.showFrozen(mContext);
                            return;
                        }
                        if (onButtonClickListener != null) {
                            onButtonClickListener.toComment(item.getSh_order().getSh_order_no());
                        }
                    }
                });
            } else {
                tv_comment.setVisibility(View.GONE);
            }

            TextView tv_share_btn = helper.getView(R.id.tv_share_btn);
            if (item.getSh_button().getSh_share()!=null && item.getSh_button().getSh_share().equals("1")) {
                tv_share_btn.setVisibility(View.VISIBLE);
            } else {
                tv_share_btn.setVisibility(View.GONE);
            }

            tv_share_btn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (onButtonClickListener != null) {
                        onButtonClickListener.payShare(item.getSh_order().getSh_order_no());
                    }
                }
            });

            ((PriceIntegralLayout) helper.getView(R.id.ll_price)).floadSize(0.7f);
            if ("purchase".equals(fromType)||"sale".equals(fromType)){
                int colorPurchase = Color.parseColor("#FF6809");
                ((PriceIntegralLayout) helper.getView(R.id.ll_price)).setPriceTextColor("purchase".equals(fromType)
                        ?colorPurchase:Color.parseColor("#141922"));
                ((TextView)helper.getView(R.id.tv_status)).setTextColor(colorPurchase);
                tv_delete_order.setTextColor(colorPurchase);
                tv_delete_order.setBackgroundResource(R.drawable.shape_round_line_ff6809);
                tv_pay.setTextColor(colorPurchase);
                tv_pay.setBackgroundResource(R.drawable.shape_round_line_ff6809);
                tv_confirm_order.setTextColor(colorPurchase);
                tv_confirm_order.setBackgroundResource(R.drawable.shape_round_line_ff6809);
                tv_comment.setTextColor(colorPurchase);
                tv_comment.setBackgroundResource(R.drawable.shape_round_line_ff6809);
            }

        }


        //销售订单只存在order没有trade
        LinearLayout sale_layout_seller_name = helper.getView(R.id.sale_layout_seller_name);
        TextView sale_tag_seller_name = helper.getView(R.id.sale_tag_seller_name);
        TextView sale_tv_seller_name = helper.getView(R.id.sale_tv_seller_name);
        sale_layout_seller_name.setVisibility("sale".equals(fromType) ? View.VISIBLE : View.GONE);
        tv_shop_name.setVisibility("sale".equals(fromType) ? View.GONE : View.VISIBLE);

        if ("sale".equals(fromType)) {
            sale_tag_seller_name.setText(item.getSh_order().getBuyer_name_prefix());
            sale_tv_seller_name.setText(item.getSh_order().getBuyer_name());
//            boolean buyerType = "1".equals(item.getSh_order().getBuyer_type());
//            TextView saleTagUser = helper.getView(R.id.sale_tag_user);
//            saleTagUser.setVisibility(TextUtils.isEmpty(item.getSh_order().getBuyer_type()) ? View.GONE : View.VISIBLE);
//            if (TextUtils.isEmpty(item.getSh_order().getBuyer_type())) {
//                saleTagUser.setText(item.getSh_order().getBuyer_type_label());
//                saleTagUser.setTextColor(Color.parseColor(buyerType?"#FF5000":"#F23051"));
//                saleTagUser.setBackgroundResource(buyerType?R.drawable.shape_radius_fff0e7:R.drawable.shape_radius_ffecec);
//                iv_shop_arrow.setVisibility(buyerType?View.GONE:View.VISIBLE);
//            }
            helper.setText(R.id.tv_goods_num, item.getSh_order().getProduct_num());


            ll_shop.setOnClickListener(v -> {
                if (!TextUtils.isEmpty(item.getSh_order().getFans_id())){
//                    ARouter.getInstance().build(AroutePath.VIP_TEAM_DETAILS_ACTIVITY).withString
//                            ("id",item.getSh_order().getFans_id()).navigation();
                }
            });

            View rl_title_line = helper.getView(R.id.rl_title_line);
            // 文字描述
            OrderTipBean tipBean = item.getSh_order().getTips();
            TextView saleDescButtonName = helper.getView(R.id.sale_desc_button_name);
            LinearLayout saleDescButton = helper.getView(R.id.sale_desc_button);
            TextView saleDescTv = helper.getView(R.id.sale_desc_tv);
            ImageView saleDescLogo = helper.getView(R.id.sale_desc_logo);
            LinearLayout saleDescLayout = helper.getView(R.id.sale_desc_layout);
            if (tipBean==null || TextUtils.isEmpty(tipBean.getText())){
                saleDescLayout.setVisibility(View.GONE);
                rl_title_line.setVisibility(View.VISIBLE);
            }else {
                ViewTransformUtil.glideImageView(mContext,tipBean.getIcon(),saleDescLogo,R.mipmap.defaults);
                saleDescTv.setText(tipBean.getText());
                saleDescLayout.setVisibility(View.VISIBLE);
                rl_title_line.setVisibility(View.GONE);
                if (!TextUtils.isEmpty(tipBean.getBtn_text())) {
                    saleDescButtonName.setText(tipBean.getBtn_text());
                    saleDescButtonName.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);
                    saleDescButton.setOnClickListener(v -> {
                    if ("view_lading".equals(tipBean.getBtn_target())){
                        Intent intentOrderDetail = new Intent(mContext, OrderDetailActivity.class);
                        intentOrderDetail.putExtra("order_no",tipBean.getBtn_target_val());
                        intentOrderDetail.putExtra("from_type", "purchase");
                        mContext.startActivity(intentOrderDetail);
                    }else if ("down_lading".equals(tipBean.getBtn_target())){
                        onButtonClickListener.toPickUp(helper.getAdapterPosition(),tipBean.getBtn_target_val(),"pick_up");
                    }else if ("to_purchase".equals(tipBean.getBtn_target())){
                        ARouter.getInstance().build(AroutePath.PURCHASE_ACTIVITY).navigation();
                    }else if ("view_purchase".equals(tipBean.getBtn_target())){
                        Intent intentOrderDetail = new Intent(mContext, OrderDetailActivity.class);
                        intentOrderDetail.putExtra("order_no",tipBean.getBtn_target_val());
                        intentOrderDetail.putExtra("from_type", "purchase");
                        mContext.startActivity(intentOrderDetail);
                    }
                        });
                    saleDescButton.setVisibility(View.VISIBLE);
                }else {
                    saleDescButton.setVisibility(View.GONE);
                }
            }



            LinearLayout ll_countdown = helper.getView(R.id.ll_countdown);
            TextView tvCountdown = helper.getView(R.id.tv_countdown);
            Utils.setDin(tvCountdown,mContext);
            TimeUtil.orderBtnCountdown(tvCountdown,item.getSh_order().getCount_down_second());
            ll_countdown.setVisibility(item.getSh_order().getCount_down_second()>0?View.VISIBLE:View.GONE);

            helper.getView(R.id.layout_countdown).setOnClickListener(v ->{});


            ll_op.setVisibility("sale".equals(fromType)?View.GONE:View.VISIBLE);
            ll_op_sale.setVisibility("1".equals(item.getSh_button().getUp_reserve_btn())||
                    "1".equals(item.getSh_button().getPick_up_btn())|| "1".equals(item.getSh_button()
                    .getSend_btn())||"1".equals(item.getSh_button().getDelivery_btn())||"1".equals
                    (item.getSh_button().getAdd_track_btn())||"1".equals(item.getSh_button()
                    .getView_track_btn())?View.VISIBLE:View.GONE);

            TextView tvUpReserve = helper.getView(R.id.tv_up_reserve);
            if ("1".equals(item.getSh_button().getUp_reserve_btn())){
                ll_op_sale.setVisibility(View.VISIBLE);
                tvUpReserve.setVisibility(View.VISIBLE);
                tvUpReserve.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        ConfirmDialog dialog = new ConfirmDialog(mContext, "点击确定后，该订单将会自动向上采购", "取消", "确认","#FF6809");
                        dialog.setOnChooseListerner(new ConfirmDialog.OnChooseListerner() {
                            @Override
                            public void cancel() {
                                dialog.dismiss();
                            }

                            @Override
                            public void confirm() {
                                onButtonClickListener.toUpReserve(helper.getAdapterPosition(),item.getSh_order().getSh_id());
                                dialog.dismiss();
                            }
                        });
                        dialog.show();
                    }
                });
            }else {
                tvUpReserve.setVisibility(View.GONE);
            }

            TextView tvUpPick = helper.getView(R.id.tv_up_pick);
            if ("1".equals(item.getSh_button().getPick_up_btn())){
                ll_op_sale.setVisibility(View.VISIBLE);
                tvUpPick.setVisibility(View.VISIBLE);
                tvUpPick.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        ConfirmDialog dialog = new ConfirmDialog(mContext, "使用您在公司仓库保管的库存，给您的买家发货", "取消", "确定","#FF6809");
                        dialog.setOnChooseListerner(new ConfirmDialog.OnChooseListerner() {
                            @Override
                            public void cancel() {
                                dialog.dismiss();
                            }

                            @Override
                            public void confirm() {
                                onButtonClickListener.toPickUp(helper.getAdapterPosition(),item.getSh_order().getSh_id(),"pick_up");
                                dialog.dismiss();
                            }
                        });
                        dialog.show();
                    }
                });
            }else {
                tvUpPick.setVisibility(View.GONE);
            }

            TextView tvAgainSend = helper.getView(R.id.tv_again_send);
            if ("1".equals(item.getSh_button().getAdd_track_btn())){
                ll_op_sale.setVisibility(View.VISIBLE);
                tvAgainSend.setVisibility(View.VISIBLE);
                tvAgainSend.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        onButtonClickListener.toSend(1,item.getSh_order().getSh_id());
                    }
                });
            }else {
                tvAgainSend.setVisibility(View.GONE);
            }

            TextView tvSend = helper.getView(R.id.tv_send);
            if ("1".equals(item.getSh_button().getSend_btn())){
                ll_op_sale.setVisibility(View.VISIBLE);
                tvSend.setVisibility(View.VISIBLE);
                tvSend.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        onButtonClickListener.toSend(0,item.getSh_order().getSh_id());
                    }
                });
            }else {
                tvSend.setVisibility(View.GONE);
            }

            TextView tvSendDelivery = helper.getView(R.id.tv_send_delivery);
            if ("1".equals(item.getSh_button().getDelivery_btn())){
                ll_op_sale.setVisibility(View.VISIBLE);
                tvSendDelivery.setVisibility(View.VISIBLE);
                tvSendDelivery.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        ConfirmDialog dialog = new ConfirmDialog(mContext, "给ta充库存后，库存将会划转给下级经销商", "取消", "给ta充库存","#FF6809");
                        dialog.setOnChooseListerner(new ConfirmDialog.OnChooseListerner() {
                            @Override
                            public void cancel() {
                                dialog.dismiss();
                            }

                            @Override
                            public void confirm() {
                                onButtonClickListener.toSendDelivery(helper.getAdapterPosition(),item.getSh_order().getSh_id());
                                dialog.dismiss();
                            }
                        });
                        dialog.show();
                    }
                });
            }else {
                tvSendDelivery.setVisibility(View.GONE);
            }

            TextView tv_sale_logistics = helper.getView(R.id.tv_sale_logistics);
            if ("1".equals(item.getSh_button().getView_track_btn())) {
                ll_op_sale.setVisibility(View.VISIBLE);
                tv_sale_logistics.setVisibility(View.VISIBLE);
                tv_sale_logistics.setOnClickListener(v -> {
                    if (onButtonClickListener != null) {
                        onButtonClickListener.getLogistInfo(item.getSh_order().getSh_id(),
                                item.getSh_order().getSh_order_type());
                    }
                });
            } else {
                tv_sale_logistics.setVisibility(View.GONE);
            }
        }

    }

    public void setOnButtonClickListener(OnButtonClickListener onButtonClickListener) {
        this.onButtonClickListener = onButtonClickListener;
    }

    private OnButtonClickListener onButtonClickListener;

    public interface OnButtonClickListener {
        public void recieverOrder(String id);

        public void removeOrder(String id);

        public void updateAddress(String trade_id,String order_id);

        public void cancleOrder(String reason, String id);

        public void getLogistInfo(String order_id,String order_type);

        public void toComment(String order_id);

        public void payNow(String trade_no, String type);

        public void payShare(String order_no);
        public void toUpReserve(int position,String order_id);

        public void toSend(int type, String order_id);

        public void toPickUp(int position,String order_id, String type);

        public void toSendDelivery(int position,String order_id);
    }
}
